<?php
class helper {
	
	/**
	 * 自动生成如 /aa/bb/cc 这样的深层目录
	 * @author	mouse
	 * @param	string		$path		目录路径
	 * @return	void
	 */
	function mkdirs( $path )
	{
		if ( $path == '' ) return false;
		$path = explode( '/', $path );
		$mk = '/';
		foreach ( $path as $dir )
		{
			if ( $dir )
			{
				$mk .= $dir . '/';
				if ( ! file_exists( $_SERVER['DOCUMENT_ROOT'] . $mk ) )
				{
					mkdir( $_SERVER['DOCUMENT_ROOT'] . '/' . $mk, 0777 );
					// http://www.yanghengfei.com/archives/481/
					chmod( $_SERVER['DOCUMENT_ROOT'] . '/' . $mk, 0777 );
				}
			}
		}
	}
}